#!/bin/sh /etc/rc.common

START=90
STOP=15
PIDFILE='/tmp/run/chinadns.pid'

start()
{
	config_load "chinadns"
	local enabled dns port
	config_get enabled config enabled
	config_get dns config dns
	config_get port config port

	[ $enabled = '0' ] && exit 0

	if [ -f $PIDFILE ];then
		echo "already started: $PIDFILE exists"
		return 1
	fi

	chinadns \
		-c /etc/chinadns_chnroute.txt \
		-m \
		-p $port \
		-s "$dns" &
	echo $! > $PIDFILE
}

stop()
{
	[ -f $PIDFILE ] && {
		kill -9 `cat $PIDFILE`
		rm $PIDFILE
	}
}
